//- Copyright (c) 2016 Lucky Byte, Inc.
extends ../../table

block form_items
  .field.two.wide
    .ui.calendar.date#start_date(data-end-with="#end_date"
      data-maxdate="#{today()}")
      .ui.input.left.icon
        i.calendar.icon
        input(type="text" name="start_date" placeholder="起始日期"
          value="#{start_date || ''}")
  .field.two.wide
    .ui.calendar.date#end_date(data-start-with="#start_date"
      data-maxdate="#{today()}")
      .ui.input.right.icon
        input(type="text" name="end_date" placeholder="结束日期"
          value="#{end_date || ''}")
        i.remove.link.icon#date_clear

  .field.nine.wide
    .ui.buttons.right.floated
      button#new.ui.green.button(type="submit") 查 询
      button.ui.red.button(type="button"
        onclick="window.location = '/p2/fund/alter/export/#{uuid}" +
          "?keyword=#{keyword}&start_date=#{start_date}&end_date=#{end_date}'") 下 载
      button.ui.blue.button(type="button"
        onclick="window.location = '/p2/fund'") 返回资金池管理

block thead
  tr
    th.center.aligned
    th.center.aligned 序号
    th.center.aligned 变动时间
    th.center.aligned 变动类型
    th.center.aligned 变动金额
    th.center.aligned 变动前余额
    th.center.aligned 变动后余额
    th.center.aligned 商户编号
    th.center.aligned 终端编号
    th.center.aligned 资金池代号
    th.center.aligned 代理商名称
    th.center.aligned 联系人
    th.center.aligned 备 注

block tbody
  each record in records
    - var lessthan0 = false
    if parseFloat(record.amt) < 0
      - lessthan0 = true
    tr(class="#{lessthan0 ? 'warning' : ''}")
      td.center.aligned.collapsing
        if lessthan0
          i.icon.plus.green
        else
          i.icon.minus.red

      td.center.aligned.collapsing= record.serial
      td.center.aligned.collapsing= record.ctime.format('YYYY-MM-DD HH:mm:ss')
      td.center.aligned.collapsing
        case record.type
          when 1
            | 充值
          when 2
            | 手续费
          default
            | 未知
      td.center.aligned.collapsing= fmtamt(0 - parseFloat(record.amt))
      td.center.aligned.collapsing= fmtamt(record.remains)
      td.center.aligned.collapsing
        = fmtamt(parseFloat(record.remains) - parseFloat(record.amt))
      td.center.aligned.collapsing= record.merno || ''
      td.center.aligned.collapsing= record.termid || ''
      td.center.aligned.collapsing= record.fund_name
      td.center.aligned= record.fund_agent
      td.center.aligned.collapsing= record.fund_contact
      td.center.aligned= record.notes || ''
  else
    td.center.aligned.warning(colspan="13") 无数据
